<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
    }
    .box{
      width: 1200px;
      height: 400px;
      border: 1px solid red;
      margin: 50px auto;
      position: relative;
      overflow: hidden;
    }
    li{
      width: 1200px;
      height: 400px;
      position: absolute;
    }
  </style>
</head>
<body>
  <div class="box">
    <ul>
      <li style="background-image: url('images/1.jpg'); left: 0px;"></li>
      <li style="background-image: url('images/2.jpg'); left: 240px;"></li>
      <li style="background-image: url('images/3.jpg'); left: 480px;"></li>
      <li style="background-image: url('images/4.jpg'); left: 720px;"></li>
      <li style="background-image: url('images/5.jpg'); left: 960px;"></li>
    </ul>
  </div>
  <script src="../../jquery-1.12.4.min.js"></script>
  <script>
    var $lis = $('li');
    //鼠标进入时候的操作
    $lis.mouseenter(function(){
      var suoyin = $(this).index();
      $lis.each(function(i,element){
        if(i <= suoyin){
          $(element).stop().animate({left:i*100});
        }else{
          $(element).stop().animate({left:i*100+700});
        };
      });
    });
    //鼠标离开时候的操作
    $('.box').mouseleave(function(){
      $lis.each(function(i,element){
        $(element).stop().animate({left:i*240});
      });
    });
  </script>
</body>
</html>